package com.wf.model.enums;


import java.util.HashMap;
import java.util.Map;

public enum ResultCode {
	// 
	SUCCESS(1, "Success"),
	//
	UNAUTHORIZED(401, "Unauthorized"),
	//
	NOT_FOUND(404, "Resource not found"),
	//
	INTERNAL_ERROR(500, "Server internal error"),
	//
	INVALID_ARGUMENT(11001, "Invalid argument"),
	//错误的参数，原参数已修改， 页面需重新刷新
	INVALID_ARGUMENT_2(11002, "Invalid argument"),

	//错误的参数，原参数已修改， 页面需重新刷新
	INVALID_CUSTOM(12001, "custom repeat"),

	//
	THIRDPLANT_BUZERROR(700, "Business error"),
	//
	UNKNOWN(-1, "Unknown error");

	private static final Map<Integer, ResultCode> values = new HashMap<Integer, ResultCode>();
	static {
		for (ResultCode ec : ResultCode.values()) {
			values.put(ec.code, ec);
		}
	}

	private int code;
	private String name;

	private ResultCode(int code, String name) {
		this.code = code;
		this.name = name;
	}

	public static ResultCode valueOf(int code) {
		ResultCode ec = values.get(code);
		if (ec != null)
			return ec;
		return UNKNOWN;
	}

	public int getCode() {
		return code;
	}

	public String getName() {
		return name;
	}
}